package com.apes.hr.group.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.hr.base.model.Employee;
import com.apes.hr.group.model.DingDingPerson;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author ZhengZeXian
 * @create 2020年11月23日10:49:00
 */
public interface DingDingPersonRepository extends CustomRepository<DingDingPerson, String> {

    /**
     * 根据员工查找对应的钉钉ID
     */
    DingDingPerson findByEmployee(Employee employee);

    /**
     * 查找所有的钉钉ID
     * @return userIdList
     */
    @Query(value = "SELECT t.ding_ding_user_id FROM hr_ding_ding_person t ",nativeQuery = true)
    List<String> findAllUserId();

    /**
     * 根据人员档案ID查找对应钉钉ID
     * @param id 人员档案ID
     * @return 钉钉ID
     */
    @Query(value = "SELECT t.ding_ding_user_id FROM hr_ding_ding_person t WHERE t.employee_id = :id",nativeQuery = true)
    String findByEmployeeId(@Param("id") String id);
}
